
package org.vasil.jouikov.testmongodb

import org.vasil.jouikov.db.MongoService
import org.vasil.jouikov.schema.Item
import org.vasil.jouikov.service.*

def db = new MongoService()
//def item1 = db.getItem('712000514-31')
//println "item1=$item1"
//item1.etilize.espec.each { key, val ->
//    println "$key: $val"
//}

def xml = new XmlService()
def items = xml.getItems(XmlMold.DESC712000514_31)

items.each { item ->
    println "item=[$item]"

    switch(item.action) {
        case 'price':
            println "price sku=${item.sku}"
            db.updateItemPrice(item)
            break
        case 'desc':
            println "desc sku=${item.sku}"
            db.updateItem(item)
            break
        case 'delete':
            println "delete sku=${item.sku}"
            db.deleteItem(item.sku)
            break
        default:
            println "sku: ${items.sku} error: $item"
    }
}

